package com.jldx.oa.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jldx.oa.bean.User;

public class BaseController extends Controller {

	public Integer getPage(){
		//http://localhost/data.json?page=2&limit=30
		return getParaToInt("page");
	}
	
	public Integer getLimit(){
		return getParaToInt("limit");
	}
	
	public void view(String path){
		render("/WEB-INF/views/" + path);
	}
	
	public void m(String path){
		render("/WEB-INF/m/" + path);
	}
	
	public User getCurrentUser(){
		return getSessionAttr("lg_user");
	}
	
	public User getCurrentCustomer(){
		return getSessionAttr("lg_customer");
	}
	
	public void refreshTaskCount(){
		Record record = Db.findFirst("select count(*) c from task where state = '0' and creator = ?",getCurrentUser().getId());
		setSessionAttr("tc", record.get("c"));
	}
}
